<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="zh-cn">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="renderer" content="webkit">
  <title></title>
  <link rel="stylesheet" href="../css/pintuer.css">
  <link rel="stylesheet" href="../css/admin.css">
  <script src="../js/jquery.js"></script>
  <script src="../js/pintuer.js"></script>
  </head>
  <body>
    <div class="panel admin-panel">
      <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加缺课记录</strong></div>
      <div class="body-content">
        <form method="post" class="form-x" action="/addAttendance">
          <div class="form-group" >
            <div class="label">
              <label>缺课记录日期：</label>
            </div>
            <div class="field">
              <input type="date" class="input w50" style="width: 300px;" name="absencedate" id="date" data-validate="required:请选择缺课日期" />
              <div class="tips"></div>
              <script>
                var time = new Date();
                var day = ("0" + time.getDate()).slice(-2);
                var month = ("0" + (time.getMonth() + 1)).slice(-2);
                var today = time.getFullYear() + "-" + (month) + "-" + (day);
                document.getElementById("date").value=today;
              </script>
            </div>
          </div>
          <div class="form-group">
            <div class="label">
              <label>第几节课缺课：</label>
            </div>
            <div class="field">
              <select name="count" id="count" class="input w50" style="width: 300px;">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
              </select>
            </div>
          </div>
          <div class="form-group">
            <div class="label">
              <label>缺课课程名称：</label>
            </div>
            <div class="field">
              <input type="text" id="lessonname" name="lessonname" class="input" style="width:300px; float:left;" data-toggle="hover" data-place="right" data-validate="required:请输入缺课课程名称" />
            </div>
          </div>
          <div class="form-group" >
            <div class="label">
              <label>学生学号：</label>
            </div>
            <div class="field">
              <input type="number" id="studentnumber" name="studentnumber" class="input" style="width:300px; float:left;"  data-toggle="hover" data-place="right" data-validate="required:请输入学生学号" />
            </div>
          </div>
          <div class="form-group" >
            <div class="label">
              <label>缺课类型：</label>
            </div>
            <div class="field">
              <select name="type" id="type" class="input w50"  style="width: 300px;">
                <option value="迟到">迟到</option>
                <option value="早退">早退</option>
                <option value="旷课">旷课</option>
              </select>
              <div class="tips"></div>
            </div>
          </div>
          <div class="form-group" style="margin-left: 15%">
            <div class="field">
              <input type="button"  id="sub" class="input w50" style="width:10%; float:left;" value="提交"/>
              <div class="tips"></div>
            </div>
          </div>
        </form>
        <script>
          $("#sub").click(function () {
            var studentnumber=$("#studentnumber").val();
            $.post("/searchById",{id:studentnumber,name:'',sex:0,age:18,studentclass:"1882072"},function (data) {
                if(data=='1'){
                  var id=0;
                  var date=$("#date").val();
                  var count=$("#count").val();
                  var lessonname=$("#lessonname").val();
                  var type=$("#type").val();
                  $.post("/addAttendance",{id:id,absencedate:date,count:count,lessonname:lessonname,studentnumber:studentnumber,type:type},function (data) {
                    alert(data);
                  },"json");
                }else {
                  alert("该学号不存在");
                  $("#studentnumber").val('');
                }
            },"json");
          });
        </script>
      </div>
    </div>
  </body>
</html>